home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / Gimp.pm < prev    next >
Encoding:
Perl POD Document  |  2003-01-14  |  57.4 KB  |  1,917 lines

  1. package Gimp;
  2.  
  3. use strict 'vars';
  4. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD %EXPORT_TAGS @EXPORT_FAIL
  5.             $interface_pkg $interface_type
  6.             @PREFIXES $_PROT_VERSION
  7.             @gimp_gui_functions $function $basename $spawn_opts
  8.             $in_quit $in_run $in_net $in_init $in_query $no_SIG
  9.             $help $verbose $host $in_top);
  10. use subs qw(init end lock unlock canonicalize_color);
  11.  
  12. BEGIN {
  13.    $VERSION = 1.211;
  14.    eval {
  15.       require XSLoader;
  16.       XSLoader::load Gimp $VERSION;
  17.    } or do {
  18.       require DynaLoader;
  19.       @ISA=qw(DynaLoader);
  20.       bootstrap Gimp $VERSION;
  21.    }
  22. }
  23.  
  24. my @_param = qw(
  25.     PDB_BOUNDARY    PDB_CHANNEL    PDB_COLOR    PDB_DISPLAY    PDB_DRAWABLE
  26.     PDB_END        PDB_FLOAT    PDB_IMAGE    PDB_INT32    PDB_FLOATARRAY
  27.     PDB_INT16    PDB_PARASITE    PDB_STRING    PDB_PATH    PDB_INT16ARRAY
  28.     PDB_INT8    PDB_INT8ARRAY    PDB_LAYER    PDB_REGION    PDB_STRINGARRAY
  29.     PDB_SELECTION    PDB_STATUS    PDB_INT32ARRAY
  30. );
  31.  
  32. # constants that, in some earlier version, were autoloaded
  33. my @_consts = (@_param,
  34. #ENUM_NAME#
  35. 'PRESSURE',            'SOFT',                'HARD',                'RGBA_IMAGE',          'INDEXED_IMAGE',       'GRAYA_IMAGE',         'RGB_IMAGE',           
  36. 'INDEXEDA_IMAGE',      'GRAY_IMAGE',          'CUSTOM',              'FG_BG_HSV',           'FG_TRANS',            'FG_BG_RGB',           'BLUE_CHANNEL',        
  37. 'GREEN_CHANNEL',       'GRAY_CHANNEL',        'AUXILLARY_CHANNEL',   'INDEXED_CHANNEL',     'RED_CHANNEL',         'CONTINUOUS',          'INCREMENTAL',         
  38. 'APPLY',               'DISCARD',             'UNKNOWN',             'VERTICAL',            'HORIZONTAL',          'DODGEBURN_HIGHLIGHTS','DODGEBURN_SHADOWS',   
  39. 'DODGEBURN_MIDTONES',  'CUBIC_INTERPOLATION', 'LINEAR_INTERPOLATION','NEAREST_NEIGHBOR_INTERPOLATION','ALPHA_LUT',           'GREEN_LUT',           'BLUE_LUT',            
  40. 'VALUE_LUT',           'RED_LUT',             'OFFSET_BACKGROUND',   'OFFSET_TRANSPARENT',  'BG_BUCKET_FILL',      'FG_BUCKET_FILL',      'PATTERN_BUCKET_FILL', 
  41. 'FSLOWBLEED_DITHER',   'NODESTRUCT_DITHER',   'FS_DITHER',           'NO_DITHER',           'FIXED_DITHER',        'PDB_CANCEL',          'PDB_SUCCESS',         
  42. 'PDB_CALLING_ERROR',   'PDB_EXECUTION_ERROR', 'PDB_PASS_THROUGH',    'WHITE_IMAGE_FILL',    'FG_IMAGE_FILL',       'TRANS_IMAGE_FILL',    'BG_IMAGE_FILL',       
  43. 'NO_IMAGE_FILL',       'LOOP_SAWTOOTH',       'ONCE_BACKWARDS',      'ONCE_FORWARD',        'ONCE_END_COLOR',      'LOOP_TRIANGLE',       'MONO_PALETTE',        
  44. 'WEB_PALETTE',         'MAKE_PALETTE',        'REUSE_PALETTE',       'CUSTOM_PALETTE',      'BURN',                'DODGE',               'CYAN_HUES',           
  45. 'RED_HUES',            'GREEN_HUES',          'YELLOW_HUES',         'ALL_HUES',            'MAGENTA_HUES',        'BLUE_HUES',           'POINTS',              
  46. 'PIXELS',              'DIVIDE_MODE',         'SUBTRACT_MODE',       'SATURATION_MODE',     'ADDITION_MODE',       'SCREEN_MODE',         'BEHIND_MODE',         
  47. 'MULTIPLY_MODE',       'DARKEN_ONLY_MODE',    'DIFFERENCE_MODE',     'DISSOLVE_MODE',       'VALUE_MODE',          'LIGHTEN_ONLY_MODE',   'COLOR_MODE',          
  48. 'NORMAL_MODE',         'HUE_MODE',            'OVERLAY_MODE',        'NEGATIVE_CONVOL',     'NORMAL_CONVOL',       'ABSOLUTE_CONVOL',     'BLUR_CONVOLVE',       
  49. 'CUSTOM_CONVOLVE',     'SHARPEN_CONVOLVE',    'REPLACE',             'SUB',                 'ADD',                 'INTERSECT',           'SHADOWS',             
  50. 'MIDTONES',            'HIGHLIGHTS',          'IMAGE_CLONE',         'PATTERN_CLONE',       'INDEXED',             'RGB',                 'GRAY',                
  51. 'BLACK_MASK',          'WHITE_MASK',          'ALPHA_MASK',          'BILINEAR',            'SPIRAL_CLOCKWISE',    'SQUARE',              'RADIAL',              
  52. 'CONICAL_SYMMETRIC',   'SHAPEBURST_DIMPLED',  'CONICAL_ASYMMETRIC',  'LINEAR',              'SPIRAL_ANTICLOCKWISE','SHAPEBURST_ANGULAR',  'SHAPEBURST_SPHERICAL',
  53. 'PLUGIN',              'EXTENSION',           'TEMPORARY',           'INTERNAL',            'MESSAGE_BOX',         'ERROR_CONSOLE',       'CONSOLE',             
  54. 'STACK_TRACE_ALWAYS',  'STACK_TRACE_QUERY',   'STACK_TRACE_NEVER',   'EXPAND_AS_NECESSARY', 'CLIP_TO_BOTTOM_LAYER','CLIP_TO_IMAGE',       'FLATTEN_IMAGE',       
  55. 'RUN_INTERACTIVE',     'RUN_WITH_LAST_VALS',  'RUN_NONINTERACTIVE',  'REPEAT_NONE',         'REPEAT_SAWTOOTH',     'REPEAT_TRIANGULAR',   
  56. #ENUM_NAME#
  57.     'PDB_CALLING_ERROR',        'PDB_EXECUTION_ERROR',        'PDB_PASS_THROUGH',
  58.         'PDB_SUCCESS',            'PARASITE_PERSISTENT',        'PARASITE_ATTACH_PARENT',
  59.         'PARASITE_PARENT_PERSISTENT',    'PARASITE_ATTACH_GRANDPARENT',    'PARASITE_GRANDPARENT_PERSISTENT',
  60.         'PARASITE_UNDOABLE',        'PARASITE_PARENT_UNDOABLE',    'PARASITE_GRANDPARENT_UNDOABLE',
  61.     'TRACE_NONE',    'TRACE_CALL',    'TRACE_TYPE',    'TRACE_NAME',    'TRACE_DESC',    'TRACE_ALL',
  62.     'COMPRESSION_NONE',        'COMPRESSION_LZW',        'COMPRESSION_PACKBITS',
  63.         'WRAP',                'SMEAR',            'BLACK',
  64.  
  65.         'ADD_BLACK_MASK',        'ADD_WHITE_MASK',        'ADD_ALPHA_MASK',
  66.  
  67.     'EXPORT_CAN_HANDLE_RGB',    'EXPORT_CAN_HANDLE_GRAY',    'EXPORT_CAN_HANDLE_INDEXED',
  68.         'EXPORT_CAN_HANDLE_ALPHA ',    'EXPORT_CAN_HANDLE_LAYERS',    'EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION',
  69.         'EXPORT_NEEDS_ALPHA',
  70.     'EXPORT_CANCEL',        'EXPORT_IGNORE',        'EXPORT_EXPORT',
  71. );
  72.  
  73. sub ADD_WHITE_MASK    () { &WHITE_MASK }
  74. sub ADD_BLACK_MASK    () { &BLACK_MASK }
  75. sub ADD_ALPHA_MASK    () { &ALPHA_MASK }
  76.  
  77. #ENUM_DEFS#
  78. sub PRESSURE            (){ 2} sub SOFT                (){ 1} sub HARD                (){ 0} sub RGBA_IMAGE          (){ 1} sub INDEXED_IMAGE       (){ 4}
  79. sub GRAYA_IMAGE         (){ 3} sub RGB_IMAGE           (){ 0} sub INDEXEDA_IMAGE      (){ 5} sub GRAY_IMAGE          (){ 2} sub CUSTOM              (){ 3}
  80. sub FG_BG_HSV           (){ 1} sub FG_TRANS            (){ 2} sub FG_BG_RGB           (){ 0} sub BLUE_CHANNEL        (){ 2} sub GREEN_CHANNEL       (){ 1}
  81. sub GRAY_CHANNEL        (){ 3} sub AUXILLARY_CHANNEL   (){ 5} sub INDEXED_CHANNEL     (){ 4} sub RED_CHANNEL         (){ 0} sub CONTINUOUS          (){ 0}
  82. sub INCREMENTAL         (){ 1} sub APPLY               (){ 0} sub DISCARD             (){ 1} sub UNKNOWN             (){ 2} sub VERTICAL            (){ 1}
  83. sub HORIZONTAL          (){ 0} sub DODGEBURN_HIGHLIGHTS(){ 0} sub DODGEBURN_SHADOWS   (){ 2} sub DODGEBURN_MIDTONES  (){ 1} sub CUBIC_INTERPOLATION (){ 1}
  84. sub LINEAR_INTERPOLATION(){ 0} sub NEAREST_NEIGHBOR_INTERPOLATION(){ 2} sub ALPHA_LUT           (){ 4} sub GREEN_LUT           (){ 2} sub BLUE_LUT            (){ 3}
  85. sub VALUE_LUT           (){ 0} sub RED_LUT             (){ 1} sub OFFSET_BACKGROUND   (){ 0} sub OFFSET_TRANSPARENT  (){ 1} sub BG_BUCKET_FILL      (){ 1}
  86. sub FG_BUCKET_FILL      (){ 0} sub PATTERN_BUCKET_FILL (){ 2} sub FSLOWBLEED_DITHER   (){ 2} sub NODESTRUCT_DITHER   (){ 4} sub FS_DITHER           (){ 1}
  87. sub NO_DITHER           (){ 0} sub FIXED_DITHER        (){ 3} sub PDB_CANCEL          (){ 4} sub PDB_SUCCESS         (){ 3} sub PDB_CALLING_ERROR   (){ 1}
  88. sub PDB_EXECUTION_ERROR (){ 0} sub PDB_PASS_THROUGH    (){ 2} sub WHITE_IMAGE_FILL    (){ 2} sub FG_IMAGE_FILL       (){ 0} sub TRANS_IMAGE_FILL    (){ 3}
  89. sub BG_IMAGE_FILL       (){ 1} sub NO_IMAGE_FILL       (){ 4} sub LOOP_SAWTOOTH       (){ 2} sub ONCE_BACKWARDS      (){ 1} sub ONCE_FORWARD        (){ 0}
  90. sub ONCE_END_COLOR      (){ 4} sub LOOP_TRIANGLE       (){ 3} sub MONO_PALETTE        (){ 3} sub WEB_PALETTE         (){ 2} sub MAKE_PALETTE        (){ 0}
  91. sub REUSE_PALETTE       (){ 1} sub CUSTOM_PALETTE      (){ 4} sub BURN                (){ 1} sub DODGE               (){ 0} sub CYAN_HUES           (){ 4}
  92. sub RED_HUES            (){ 1} sub GREEN_HUES          (){ 3} sub YELLOW_HUES         (){ 2} sub ALL_HUES            (){ 0} sub MAGENTA_HUES        (){ 6}
  93. sub BLUE_HUES           (){ 5} sub POINTS              (){ 1} sub PIXELS              (){ 0} sub DIVIDE_MODE         (){15} sub SUBTRACT_MODE       (){ 8}
  94. sub SATURATION_MODE     (){12} sub ADDITION_MODE       (){ 7} sub SCREEN_MODE         (){ 4} sub BEHIND_MODE         (){ 2} sub MULTIPLY_MODE       (){ 3}
  95. sub DARKEN_ONLY_MODE    (){ 9} sub DIFFERENCE_MODE     (){ 6} sub DISSOLVE_MODE       (){ 1} sub VALUE_MODE          (){14} sub LIGHTEN_ONLY_MODE   (){10}
  96. sub COLOR_MODE          (){13} sub NORMAL_MODE         (){ 0} sub HUE_MODE            (){11} sub OVERLAY_MODE        (){ 5} sub NEGATIVE_CONVOL     (){ 2}
  97. sub NORMAL_CONVOL       (){ 0} sub ABSOLUTE_CONVOL     (){ 1} sub BLUR_CONVOLVE       (){ 0} sub CUSTOM_CONVOLVE     (){ 2} sub SHARPEN_CONVOLVE    (){ 1}
  98. sub REPLACE             (){ 2} sub SUB                 (){ 1} sub ADD                 (){ 0} sub INTERSECT           (){ 3} sub SHADOWS             (){ 0}
  99. sub MIDTONES            (){ 1} sub HIGHLIGHTS          (){ 2} sub IMAGE_CLONE         (){ 0} sub PATTERN_CLONE       (){ 1} sub INDEXED             (){ 2}
  100. sub RGB                 (){ 0} sub GRAY                (){ 1} sub BLACK_MASK          (){ 1} sub WHITE_MASK          (){ 0} sub ALPHA_MASK          (){ 2}
  101. sub BILINEAR            (){ 1} sub SPIRAL_CLOCKWISE    (){ 9} sub SQUARE              (){ 3} sub RADIAL              (){ 2} sub CONICAL_SYMMETRIC   (){ 4}
  102. sub SHAPEBURST_DIMPLED  (){ 8} sub CONICAL_ASYMMETRIC  (){ 5} sub LINEAR              (){ 0} sub SPIRAL_ANTICLOCKWISE(){10} sub SHAPEBURST_ANGULAR  (){ 6}
  103. sub SHAPEBURST_SPHERICAL(){ 7} sub PLUGIN              (){ 1} sub EXTENSION           (){ 2} sub TEMPORARY           (){ 3} sub INTERNAL            (){ 0}
  104. sub MESSAGE_BOX         (){ 0} sub ERROR_CONSOLE       (){ 2} sub CONSOLE             (){ 1} sub STACK_TRACE_ALWAYS  (){ 2} sub STACK_TRACE_QUERY   (){ 1}
  105. sub STACK_TRACE_NEVER   (){ 0} sub EXPAND_AS_NECESSARY (){ 0} sub CLIP_TO_BOTTOM_LAYER(){ 2} sub CLIP_TO_IMAGE       (){ 1} sub FLATTEN_IMAGE       (){ 3}
  106. sub RUN_INTERACTIVE     (){bless \(my $x=0),'Gimp::run_mode'} sub RUN_WITH_LAST_VALS  (){bless \(my $x=2),'Gimp::run_mode'} sub RUN_NONINTERACTIVE  (){bless \(my $x=1),'Gimp::run_mode'} sub REPEAT_NONE         (){ 0} sub REPEAT_SAWTOOTH     (){ 1}
  107. sub REPEAT_TRIANGULAR   (){ 2}
  108. #ENUM_DEFS#
  109.  
  110. sub WRAP        (){ 0 }
  111. sub SMEAR        (){ 1 }
  112. sub BLACK        (){ 2 }
  113.  
  114. # file_tiff_*
  115. sub COMPRESSION_NONE        (){ 0 }
  116. sub COMPRESSION_LZW        (){ 1 }
  117. sub COMPRESSION_PACKBITS    (){ 2 }
  118.  
  119. # internal constants shared with Perl-Server
  120.  
  121. sub _PS_FLAG_QUIET    { 0000000001 };    # do not output messages
  122. sub _PS_FLAG_BATCH    { 0000000002 }; # started via Gimp::Net, extra = filehandle
  123.  
  124. $_PROT_VERSION = "3";            # protocol version
  125.  
  126. sub croak {
  127.    require Carp;
  128.    goto &Carp::croak;
  129. }
  130.  
  131. my @_procs = ('main', 'xlfd_size', '__', 'N_');
  132. #my @_default = (@_procs, ':consts' ,':_auto2');
  133. my @_default = (@_procs, ':consts');
  134.    
  135. # we really abuse the import facility..
  136. sub import($;@) {
  137.    my $pkg = shift;
  138.    my $up = caller;
  139.    my @export;
  140.  
  141.    @_=@_default unless @_;
  142.    
  143.    for(map { $_ eq ":DEFAULT" ? @_default : $_ } @_) {
  144.       if ($_ eq ":auto") {
  145.          push(@export,@_consts,@_procs);
  146.          *{"$up\::AUTOLOAD"} = sub {
  147.             croak "Cannot call '$AUTOLOAD' at this time" unless initialized();
  148.             my ($class,$name) = $AUTOLOAD =~ /^(.*)::(.*?)$/;
  149.             *{$AUTOLOAD} = sub { unshift @_, 'Gimp'; $AUTOLOAD = "Gimp::$name"; goto &AUTOLOAD };
  150.             #*{$AUTOLOAD} = sub { Gimp->$name(@_) }; # old version
  151.             goto &$AUTOLOAD;
  152.          };
  153.       } elsif ($_ eq ":_auto2") {
  154.          push(@export,@_consts,@_procs);
  155.          *{"$up\::AUTOLOAD"} = sub {
  156.             warn __"$function: calling $AUTOLOAD without specifying the :auto import tag is deprecated!\n";
  157.             croak __"Cannot call '$AUTOLOAD' at this time" unless initialized();
  158.             my ($class,$name) = $AUTOLOAD =~ /^(.*)::(.*?)$/;
  159.             *{$AUTOLOAD} = sub { unshift @_, 'Gimp'; $AUTOLOAD = "Gimp::$name"; goto &AUTOLOAD };
  160.             #*{$AUTOLOAD} = sub { Gimp->$name(@_) }; # old version
  161.             goto &$AUTOLOAD;
  162.          };
  163.       } elsif ($_ eq ":consts") {
  164.          push(@export,@_consts);
  165.       } elsif ($_ eq ":param") {
  166.          push(@export,@_param);
  167.       } elsif (/^interface=(\S+)$/) {
  168.          croak __"interface=... tag is no longer supported\n";
  169.       } elsif ($_=~/spawn_options=(\S+)/) {
  170.          $spawn_opts = $1;
  171.       } elsif ($_ ne "") {
  172.          push(@export,$_);
  173.       } elsif ($_ eq "") {
  174.          #nop #d#FIXME, Perl-Server requires this!
  175.       } else {
  176.          croak __"$_ is not a valid import tag for package $pkg";
  177.       }
  178.    }
  179.    
  180.    for(@export) {
  181.       *{"$up\::$_"} = \&$_;
  182.    }
  183. }
  184.  
  185. sub xlfd_size($) {
  186.   local $^W=0;
  187.   my ($px,$pt)=(split(/-/,$_[0]))[7,8];
  188.   $px>0 ? ($px,&Gimp::PIXELS)
  189.         : ($pt,&Gimp::POINTS);
  190. }
  191.  
  192. # the monadic identity function
  193. sub N_($) { shift }
  194.  
  195. my @init_functions;
  196.  
  197. my $gtk_init = 1;
  198.  
  199. sub gtk_init() {
  200.    if ($gtk_init) {
  201.       require Gtk;
  202.       Gtk->init;
  203.       Gtk::Rc->parse (Gimp->gtkrc);
  204.       Gtk::Gdk->set_use_xshm (Gimp->use_xshm);
  205.       Gtk::Preview->set_gamma (Gimp->gamma);
  206.       Gtk::Preview->set_install_cmap (Gimp->install_cmap);
  207.       Gtk::Preview->set_color_cube (Gimp->color_cube);
  208.       Gtk::Widget->set_default_visual (Gtk::Preview->get_visual);
  209.       Gtk::Widget->set_default_colormap (Gtk::Preview->get_cmap);
  210.       $gtk_init = 0;
  211.    }
  212.    &{shift @init_functions} while @init_functions;
  213. }
  214.  
  215. sub gtk_init_hook(&) {
  216.    push @init_functions, @_;
  217.    unless ($gtk_init) {
  218.       &{shift @init_functions} while @init_functions;
  219.    }
  220. }
  221.  
  222. # internal utility function for Gimp::Fu and others
  223. sub wrap_text {
  224.    my $x=$_[0];
  225.    $x=~s/\G(.{1,$_[1]})(\s+|$)/$1\n/gm;
  226.    $x=~s/[ \t\r\n]+$//g;
  227.    $x;
  228. }
  229.  
  230. my %rgb_db;
  231. my $rgb_db_path;
  232.  
  233. sub set_rgb_db($) {
  234.    $rgb_db_path=$_[0];
  235.    undef %rgb_db;
  236. }
  237.  
  238. sub canonicalize_colour {
  239.    if (@_ == 3) {
  240.       [@_];
  241.    } elsif (ref $_[0]) {
  242.       $_[0];
  243.    } elsif ($_[0] =~ /^#([0-9a-fA-F]{2,2})([0-9a-fA-F]{2,2})([0-9a-fA-F]{2,2})$/) {
  244.       [map {eval "0x$_"} ($1,$2,$3)];
  245.    } else {
  246.       unless (%rgb_db) {
  247.          if ($rgb_db_path) {
  248.             open RGB_TEXT,"<$rgb_db_path" or croak __"unable to open $rgb_db_path";
  249.          } else {
  250.             *RGB_TEXT=*DATA;
  251.          }
  252.          while(<RGB_TEXT>) {
  253.             next unless /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.+?)\s*$/;
  254.             $rgb_db{lc($4)}=[$1,$2,$3];
  255.          }
  256.          close RGB_TEXT;
  257.       }
  258.       if ($rgb_db{lc($_[0])}) {
  259.          return $rgb_db{lc($_[0])};
  260.       } else {
  261.          croak sprintf __"Unable to grok '%s' as colour specifier", join(",",@_);
  262.       }
  263.    }
  264. }
  265.  
  266. *canonicalize_color = \&canonicalize_colour;
  267.  
  268. ($basename = $0) =~ s/^.*[\\\/]//;
  269.  
  270. $spawn_opts = "";
  271.  
  272. # extra check for Gimp::Feature::import
  273. $in_query=0 unless defined $in_query;        # perl -w is SOOO braindamaged
  274. $in_top=$in_quit=$in_run=$in_net=$in_init=0;    # perl -w is braindamaged
  275. ($function)=$0=~/([^\/\\]+)$/;
  276.  
  277. $verbose=0;
  278.  
  279. $interface_type = "net";
  280. if (@ARGV) {
  281.    if ($ARGV[0] eq "-gimp") {
  282.       $interface_type = "lib";
  283.       # ignore other parameters completely
  284.    } else {
  285.       while(@ARGV) {
  286.          $_=shift(@ARGV);
  287.          if (/^-h$|^--?help$|^-\?$/) {
  288.             $help=1;
  289.             print __"Usage: $0 [gimp-args..] [interface-args..] [script-args..]
  290.        gimp-arguments are
  291.            -gimp <anything>           used internally only
  292.            -h | -help | --help | -?   print some help
  293.            -v | --verbose             be more verbose in what you do
  294.            --host|--tcp HOST[:PORT]   connect to HOST (optionally using PORT)
  295.                                       (for more info, see Gimp::Net(3))
  296. ";
  297.          } elsif (/^-v$|^--verbose$/) {
  298.             $verbose++;
  299.          } elsif (/^--host$|^--tcp$/) {
  300.             $host=shift(@ARGV);
  301.          } else {
  302.             unshift(@ARGV,$_);
  303.             last;
  304.          }
  305.       }
  306.    }
  307. }
  308.  
  309. my @log;
  310.  
  311. sub format_msg {
  312.    $_=shift;
  313.    "$_->[0]: $_->[2] ".($_->[1] ? "($_->[1])":"");
  314. }
  315.  
  316. sub _initialized_callback {
  317.    # load the compatibility module on older versions
  318.    if ($interface_pkg eq "Gimp::Lib") {
  319.       # this must match @max_gimp_version in Gimp::Compat
  320.       my @compat_gimp_version = (1,1);
  321.       if ((Gimp->major_version < $compat_gimp_version[0])
  322.           || (Gimp->major_version == $compat_gimp_version[0]
  323.               && Gimp->minor_version < $compat_gimp_version[1])) {
  324.          require Gimp::Compat;
  325.          $compat_gimp_version[0] == $Gimp::Compat::max_gimp_version[0]
  326.             && $compat_gimp_version[1] == $Gimp::Compat::max_gimp_version[1]
  327.                or die "FATAL: Gimp::Compat version mismatch\n";
  328.       }
  329.    }
  330.    if (@log) {
  331.       my $oldtrace = set_trace(0);
  332.       unless ($in_net || $in_query || $in_quit || $in_init) {
  333.          for(@log) {
  334.             Gimp->message(format_msg($_)) if $_->[3];
  335.          }
  336.       }
  337.       Gimp->_gimp_append_data ('gimp-perl-log', map join("\1",@$_)."\0",@log);
  338.       @log=();
  339.       set_trace($oldtrace);
  340.    }
  341. }
  342.  
  343. # message
  344. # function
  345. # fatal
  346. sub logger {
  347.    my %args = @_;
  348.    $args{message}  = "unknown message"    unless defined $args{message};
  349.    $args{function} = $function            unless defined $args{function};
  350.    $args{function} = ""                   unless defined $args{function};
  351.    $args{fatal}    = 1                    unless defined $args{fatal};
  352.    push(@log,[$basename,@args{'function','message','fatal'}]);
  353.    print STDERR format_msg($log[-1]),"\n" if !($in_query || $in_init || $in_quit) || $verbose;
  354.    _initialized_callback if initialized();
  355. }
  356.  
  357. sub die_msg {
  358.    logger(message => substr($_[0],0,-1), fatal => 1, function => 'ERROR');
  359. }
  360.  
  361. # this needs to be improved
  362. sub quiet_die {
  363.    $in_top ? exit(1) : die "IGNORE THIS MESSAGE\n";
  364. }
  365.  
  366. unless($no_SIG) {
  367.    $SIG{__DIE__} = sub {
  368.       unless ($^S || !defined $^S || $in_quit) {
  369.          die_msg $_[0];
  370.          initialized() ? &quiet_die : exit quiet_main();
  371.       } else {
  372.          die $_[0];
  373.       }
  374.    };
  375.  
  376.    $SIG{__WARN__} = sub {
  377.       unless ($in_quit) {
  378.          warn $_[0];
  379.       } else {
  380.          logger(message => substr($_[0],0,-1), fatal => 0, function => __"WARNING");
  381.       }
  382.    };
  383. }
  384.  
  385. my %callback;
  386.  
  387. sub cbchain($) {
  388.    my $cb = shift;
  389.    $callback{$cb} ? @{$callback{$cb}} : ();
  390. }
  391.  
  392. sub callback {
  393.    my $type = shift;
  394.    my @cb;
  395.    if ($type eq "-run") {
  396.       local $function = shift;
  397.       local $in_run = 1;
  398.       _initialized_callback;
  399.       {
  400.          local $^W = 0;
  401.          @cb = (
  402.             @{$callback{run}},
  403.             @{$callback{lib}},
  404.             @{$callback{$function}},
  405.          );
  406.       }
  407.       die_msg __"required callback 'run' not found\n" unless @cb;
  408.       my @res;
  409.       for (@cb) { @res = &$_ }
  410.       return wantarray ? @res : $res[0];
  411.    } elsif ($type eq "-net") {
  412.       local $in_net = 1;
  413.       _initialized_callback;
  414.       {
  415.          local $^W = 0;
  416.          @cb = (
  417.             @{$callback{run}},
  418.             @{$callback{net}},
  419.             @{$callback{$function}},
  420.          );
  421.       }
  422.       die_msg __"required callback 'net' not found\n" unless @cb;
  423.       for (@cb) { &$_ }
  424.    } elsif ($type eq "-query") {
  425.       local $in_query = 1;
  426.       _initialized_callback;
  427.       {
  428.          local $^W = 0;
  429.          @cb = (
  430.             @{$callback{query}},
  431.          );
  432.       }
  433.       die_msg __"required callback 'query' not found\n" unless @cb;
  434.       for (@cb) { &$_ }
  435.    } elsif ($type eq "-quit") {
  436.       local $in_quit = 1;
  437.       {
  438.          local $^W = 0;
  439.          @cb = (
  440.             @{$callback{quiet}},
  441.          );
  442.       }
  443.       for (@cb) { &$_ }
  444.    }
  445. }
  446.  
  447. sub register_callback($$) {
  448.    push(@{$callback{$_[0]}},$_[1]);
  449. }
  450.  
  451. sub on_query(&) { register_callback "query", $_[0] }
  452. sub on_net  (&) { register_callback "net"  , $_[0] }
  453. sub on_lib  (&) { register_callback "lib"  , $_[0] }
  454. sub on_run  (&) { register_callback "run"  , $_[0] }
  455.  
  456. sub main {
  457.    &{"$interface_pkg\::gimp_main"};
  458. }
  459.  
  460. # same as main, but callbacks are ignored
  461. sub quiet_main {
  462.    main;
  463. }
  464.  
  465. ##############################################################################
  466.  
  467. if ($interface_type=~/^lib$/i) {
  468.    $interface_pkg="Gimp::Lib";
  469. } elsif ($interface_type=~/^net$/i) {
  470.    $interface_pkg="Gimp::Net";
  471. } else {
  472.    croak __"interface '$interface_type' unsupported.";
  473. }
  474.  
  475. eval "require $interface_pkg" or croak "$@";
  476. $interface_pkg->import;
  477.  
  478. # create some common aliases
  479. for(qw(_gimp_procedure_available gimp_call_procedure set_trace initialized)) {
  480.    *$_ = \&{"$interface_pkg\::$_"};
  481. }
  482.  
  483. *init  = \&{"$interface_pkg\::gimp_init"};
  484. *end   = \&{"$interface_pkg\::gimp_end" };
  485. *lock  = \&{"$interface_pkg\::lock" };
  486. *unlock= \&{"$interface_pkg\::unlock" };
  487.  
  488. my %ignore_function = (DESTROY => 1);
  489.  
  490. @PREFIXES=("gimp_", "");
  491.  
  492. @gimp_gui_functions = qw(
  493.    gimp_progress_init
  494.    gimp_progress_update
  495.    gimp_displays_flush
  496.    gimp_display_new
  497.    gimp_display_delete
  498. );
  499.  
  500. sub ignore_functions(@) {
  501.    @ignore_function{@_}++;
  502. }
  503.  
  504. sub recroak($) {
  505.   $_[0] =~ s/ at \S+ line \d+.*$//s;
  506.   croak $_[0];
  507. }
  508.  
  509. sub AUTOLOAD {
  510.    my ($class,$name) = $AUTOLOAD =~ /^(.*)::(.*?)$/;
  511.    for(@{"$class\::PREFIXES"}) {
  512.       my $sub = $_.$name;
  513.       if (exists $ignore_function{$sub}) {
  514.         *{$AUTOLOAD} = sub { () };
  515.         goto &$AUTOLOAD;
  516.       } elsif (UNIVERSAL::can(Gimp::Util,$sub)) {
  517.          my $ref = \&{"Gimp::Util::$sub"};
  518.          *{$AUTOLOAD} = sub {
  519.             shift unless ref $_[0];
  520.             #goto &$ref; # does not work, PERLBUG! #FIXME
  521.             my @r = eval { &$ref };
  522.             recroak $@ if $@; wantarray ? @r : $r[0];
  523.          };
  524.          goto &$AUTOLOAD;
  525.       } elsif (UNIVERSAL::can($interface_pkg,$sub)) {
  526.          my $ref = \&{"$interface_pkg\::$sub"};
  527.          *{$AUTOLOAD} = sub {
  528.             shift unless ref $_[0];
  529.             #goto &$ref; # does not work, PERLBUG! #FIXME
  530.             my @r = eval { &$ref };
  531.             recroak $@ if $@; wantarray ? @r : $r[0];
  532.          };
  533.          goto &$AUTOLOAD;
  534.       } elsif (_gimp_procedure_available ($sub)) {
  535.          *{$AUTOLOAD} = sub {
  536.             shift unless ref $_[0];
  537.             unshift @_, $sub;
  538.             #goto &gimp_call_procedure; # does not work, PERLBUG! #FIXME
  539.             my @r = eval { gimp_call_procedure (@_) };
  540.             recroak $@ if $@; wantarray ? @r : $r[0];
  541.          };
  542.          goto &$AUTOLOAD;
  543.       }
  544.    }
  545.    croak __"function/macro \"$name\" not found in $class";
  546. }
  547.  
  548. sub _pseudoclass {
  549.   my ($class, @prefixes)= @_;
  550.   unshift(@prefixes,"");
  551.   *{"Gimp::$class\::AUTOLOAD"} = \&AUTOLOAD;
  552.   push(@{"$class\::ISA"}        , "Gimp::$class");
  553.   push(@{"Gimp::$class\::PREFIXES"}    , @prefixes); @prefixes=@{"Gimp::$class\::PREFIXES"};
  554.   push(@{"$class\::PREFIXES"}        , @prefixes); @prefixes=@{"$class\::PREFIXES"};
  555. }
  556.  
  557. _pseudoclass qw(Layer        gimp_layer_ gimp_drawable_ gimp_floating_sel_ gimp_image_ gimp_ plug_in_ perl_fu_);
  558. _pseudoclass qw(Image        gimp_image_ gimp_drawable_ gimp_ plug_in_ perl_fu_);
  559. _pseudoclass qw(Drawable    gimp_drawable_ gimp_layer_ gimp_channel_ gimp_image_ gimp_ plug_in_ perl_fu_);
  560. _pseudoclass qw(Selection     gimp_selection_);
  561. _pseudoclass qw(Channel        gimp_channel_ gimp_drawable_ gimp_selection_ gimp_image_ gimp_ plug_in_ perl_fu_);
  562. _pseudoclass qw(Display        gimp_display_ gimp_);
  563. _pseudoclass qw(Plugin        plug_in_);
  564. _pseudoclass qw(Gradients    gimp_gradients_);
  565. _pseudoclass qw(Edit        gimp_edit_);
  566. _pseudoclass qw(Progress    gimp_progress_);
  567. _pseudoclass qw(Region        );
  568. _pseudoclass qw(GimpParasite    );
  569.  
  570. # "C"-Classes
  571. _pseudoclass qw(GimpDrawable    gimp_drawable_);
  572. _pseudoclass qw(PixelRgn    gimp_pixel_rgn_);
  573. _pseudoclass qw(Tile        gimp_tile_);
  574.  
  575. # Classes without GIMP-Object
  576. _pseudoclass qw(Palette        gimp_palette_);
  577. _pseudoclass qw(Brushes        gimp_brushes_);
  578. _pseudoclass qw(Edit        gimp_edit_);
  579. _pseudoclass qw(Gradients    gimp_gradients_);
  580. _pseudoclass qw(Patterns    gimp_patterns_);
  581.  
  582. package Gimp::Tile;
  583.  
  584. unshift (@Tile::ISA, "Gimp::Tile");
  585.  
  586. package Gimp::PixelRgn;
  587.  
  588. push(@PixelRgn::ISA, "Gimp::PixelRgn");
  589.  
  590. sub new($$$$$$$$) {
  591.    shift;
  592.    init Gimp::PixelRgn(@_);
  593. }
  594.  
  595. package Gimp::Parasite;
  596.  
  597. sub is_type($$)        { $_[0]->[0] eq $_[1] }
  598. sub is_persistent($)    { $_[0]->[1] & &Gimp::PARASITE_PERSISTENT }
  599. sub is_error($)        { !defined $_[0]->[0] }
  600. sub has_flag($$)    { $_[0]->[1] & $_[1] }
  601. sub copy($)        { [@{$_[0]}] }
  602. sub name($)        { $_[0]->[0] }
  603. sub flags($)        { $_[0]->[1] }
  604. sub data($)        { $_[0]->[2] }
  605. sub compare($$)        { $_[0]->[0] eq $_[1]->[0] and
  606.               $_[0]->[1] eq $_[1]->[1] and 
  607.               $_[0]->[2] eq $_[1]->[2] }
  608. sub new($$$$)        { shift; [@_] }
  609.  
  610. package Gimp::run_mode;
  611.  
  612. # I guess I now use almost every perl feature available ;)
  613.  
  614. use overload fallback => 1,
  615.              '0+'     => sub { ${$_[0]} };
  616.  
  617. package Gimp; # for __DATA__
  618.  
  619. 1;
  620.  
  621. =cut
  622.  
  623. =head1 NAME
  624.  
  625. Gimp - Perl extension for writing Gimp Extensions/Plug-ins/Load & Save-Handlers
  626.  
  627. This is mostly a reference manual. For a quick intro, look at
  628. L<Gimp::Fu>. For more information, including tutorials, look at the
  629. Gimp-Perl pages at http://gimp.pages.de.
  630.  
  631. =head1 RATIONALE
  632.  
  633. Well, scheme (which is used by script-fu), is IMnsHO the crappiest language
  634. ever (well, the crappiest language that one actually can use, so it's not
  635. _that_ bad). Scheme has the worst of all languages, no data types, but still
  636. using variables. Look at haskell (http://www.haskell.org) to see how
  637. functional is done right.
  638.  
  639. Since I was unable to write a haskell interface (and perl is the traditional
  640. scripting language), I wrote a Perl interface instead. Not too bad a
  641. decision I believe...
  642.  
  643. =head1 SYNOPSIS
  644.  
  645.   use Gimp;
  646.   
  647.   Other modules of interest:
  648.   
  649.   use Gimp::Fu;        # easy scripting environment
  650.   use Gimp::PDL;    # interface to the Perl Data Language
  651.   
  652.   these have their own manpage.
  653.  
  654. =head2 IMPORT TAGS
  655.  
  656. If you don't specify any import tags, Gimp assumes C<qw/:consts main xlfd_size/>
  657. which may not be what you want. You may want to add :auto as in the following
  658. example:
  659.  
  660.     use Gimp qw(:consts main xlfd_size :auto);
  661.  
  662.  
  663. =over 4
  664.  
  665. =item :auto
  666.  
  667. Import useful constants, like RGB, RUN_NONINTERACTIVE... as well as all
  668. libgimp and pdb functions automagically into the caller's namespace. BEWARE!
  669. This will overwrite your AUTOLOAD function, if you have one!
  670.  
  671. =item :param
  672.  
  673. Import PARAM_* constants (PDB_INT32, PDB_STRING etc.) only.
  674.  
  675. =item :consts
  676.  
  677. All constants from gimpenums.h (BG_IMAGE_FILL, RUN_NONINTERACTIVE, NORMAL_MODE, PDB_INT32 etc.).
  678.  
  679. =item spawn_options=I<options>
  680.  
  681. Set default spawn options to I<options>, see L<Gimp::Net>.
  682.  
  683. =item :DEFAULT
  684.  
  685. The default set (see below).
  686.  
  687. =back
  688.  
  689. The default (unless '' is specified) is C<'main', 'xlfd_size', ':consts', '__'>.
  690. (C<'__'> is used for i18n purposes).
  691.  
  692. =head1 GETTING STARTED
  693.  
  694. You should first read the Gimp::Fu manpage and then come back. This manpage is mainly
  695. intended for reference purposes.
  696.  
  697. Also, Dov Grobgeld has written an excellent tutorial for Gimp-Perl. You can
  698. find it at http://imagic.weizmann.ac.il/~dov/gimp/perl-tut.html
  699.  
  700. =head1 DESCRIPTION
  701.  
  702. I think you already know what this is about: writing Gimp
  703. plug-ins/extensions/scripts/file-handlers/standalone-scripts, just about
  704. everything you can imagine in perl. If you are missing functionality (look
  705. into TODO first), please feel free contact the author...
  706.  
  707. Some hilights:
  708.  
  709. =over 2
  710.  
  711. =item *
  712. Networked plug-ins and plug-ins using the libgimp interfaces (i.e. to be
  713. started from within The Gimp) look almost the same (if you use the Gimp::Fu
  714. interface, there will be no visible differences at all), you can easily
  715. create hybrid (networked & libgimp) scripts as well.
  716.  
  717. =item *
  718. Use either a plain pdb (scheme-like) interface or nice object-oriented
  719. syntax, i.e. "gimp_image_new(600,300,RGB)" is the same as "new Image(600,300,RGB)"
  720.  
  721. =item *
  722. Gimp::Fu will start The Gimp for you, if it cannot connect to an existing
  723. gimp process.
  724.  
  725. =item *
  726. You can optionally overwrite the pixel-data functions by versions using piddles
  727. (see L<Gimp::PDL>)
  728.  
  729. =back
  730.  
  731. noteworthy limitations (subject to be changed):
  732.  
  733. =over 2
  734.  
  735. =item *
  736. callback procedures do not poass return values to The Gimp.
  737.  
  738. =back
  739.  
  740. =head1 OUTLINE OF A GIMP PLUG-IN
  741.  
  742. All plug-ins (and extensions etc.) _must_ contain a call to C<Gimp::main>.
  743. The return code should be immediately handed out to exit:
  744.  
  745.  exit main;        # Gimp::main is exported by default.
  746.  
  747. Before the call to C<Gimp::main>, I<no> other PDB function must be called.
  748.  
  749. In a C<Gimp::Fu>-script, you should call C<Gimp::Fu::main> instead:
  750.  
  751.  exit main;        # Gimp::Fu::main is exported by default as well.
  752.  
  753. This is similar to Gtk, Tk or similar modules, where you have to call the
  754. main eventloop. Attention: although you call C<exit> with the result of
  755. C<main>, the main function might not actually return. This depends on both
  756. the version of Gimp and the version of the Gimp-Perl module that is in
  757. use.  Do not depend on C<main> to return at all, but still call C<exit>
  758. immediately.
  759.  
  760. If you need to do cleanups before exiting you should use the C<quit>
  761. callback (which is not yet available if you use Gimp::Fu).
  762.  
  763. =head1 CALLBACKS
  764.  
  765. THIS SECTION IS OUTDATED AND WILL BE REWORKED SOON. USE Gimp::Fu or READ
  766. THE SOURCE :(
  767.  
  768. If you use the plain Gimp module (as opposed to Gimp::Fu), your program
  769. should only call one function: C<main>. Everything else is going to be
  770. B<called> from The Gimp at a later stage. For this to work, you should
  771. define certain call-backs in the same module you called C<Gimp::main>:
  772.  
  773. =over 4
  774.  
  775. =item init (), query (), quit ()
  776.  
  777. the standard libgimp callback functions. C<run>() is missing, because this
  778. module will directly call the function you registered with
  779. C<gimp_install_procedure>. Some only make sense for extensions, some
  780. only for normal plug-ins.
  781.  
  782. =item <installed_procedure>()
  783.  
  784. The callback for a registered function (C<gimp_install_procedure> and
  785. friends). The arguments from The Gimp are passed as normal arguments
  786. (with the exception of arrays being passed without a preceding count).
  787.  
  788. The return values from <installed_procedure>() are checked against the
  789. specification, with the exception that a single C<undef> is treated like no
  790. arguments. you can return less, but not more results than specified.
  791.  
  792. If you C<die> within the callback, the error will be reported to The Gimp
  793. (as soon as The Gimp implements such a functionality) as an execution error.
  794.  
  795. =item net ()
  796.  
  797. this is called when the plug-in is not started directly from within the
  798. Gimp, but instead from the B<Net-Server> (the perl network server extension you
  799. hopefully have installed and started ;)
  800.  
  801. =back
  802.  
  803. =head1 CALLING GIMP FUNCTIONS
  804.  
  805. There are two different flavours of gimp-functions. Functions from the
  806. B<PDB> (the Procedural DataBase), and functions from B<libgimp> (the
  807. C-language interface library).
  808.  
  809. You can get a listing and description of every PDB function by starting
  810. the B<DB Browser> extension in the Gimp-B<Xtns> menu (but remember that
  811. B<DB Browser> is buggy and displays "_" (underscores) as "-" (dashes), so
  812. you can't see the difference between gimp_quit and gimp-quit. As a rule
  813. of thumb, B<Script-Fu> in gimp versions before 1.2 registers scripts with
  814. dashes, and everything else uses underscores).
  815.  
  816. B<libgimp> functions can't be traced (and won't be traceable in the
  817. foreseeable future).
  818.  
  819. To call pdb functions (or equivalent libgimp functions), just treat them like
  820. normal perl (this requires the use of the C<:auto> import tag, but see below
  821. for another possibility!):
  822.  
  823.  gimp_palette_set_foreground([20,5,7]);
  824.  gimp_palette_set_background("cornsilk");
  825.  
  826. If you don't use the C<:auto> import tag, you can call all Gimp functions
  827. using OO-Syntax:
  828.  
  829.  Gimp->gimp_palette_set_foreground([20,5,7]);
  830.  Gimp->palette_set_background("cornsilk");
  831.  Palette->set_foreground('#1230f0');
  832.  
  833. As you can see, you can also drop part of the name prefixes with this
  834. syntax, so its actually shorter to write.
  835.  
  836. "But how do I call functions containing dashes?". Well, get your favourite
  837. perl book and learn perl! Anyway, newer perls understand a nice syntax (see
  838. also the description for C<gimp_call_procedure>):
  839.  
  840.  "Gimp::plug-in-the-egg"->(RUN_INTERACTIVE,$image,$drawable);
  841.  
  842. You can drop the C<Gimp::> when using the C<:auto>-import-tag. Very
  843. (very!) old perls may need:
  844.  
  845.  &{"Gimp::plug-in-the-egg"}("Gimp",RUN_INTERACTIVE,$image,$drawable);
  846.  
  847. (unfortunately. the plug-in in this example is actually called
  848. "plug_in_the_egg" *sigh*)
  849.  
  850. =head1 SPECIAL FUNCTIONS
  851.  
  852. In this section, you can find descriptions of special functions, functions
  853. having different calling conventions/semantics than I would expect (I
  854. cannot speak for you), or just plain interesting functions. All of these
  855. functions must either be imported explicitly or called using a namespace
  856. override (C<Gimp::>), not as Methods (C<Gimp-E<gt>>).
  857.  
  858. =over 4
  859.  
  860. =item main(), Gimp::main()
  861.  
  862. Should be called immediately when perl is initialized. Arguments are not yet
  863. supported. Initializations can later be done in the init function.
  864.  
  865. =item xlfd_size(fontname)
  866.  
  867. This auxillary functions parses the XLFD (usually obtained from a C<PF_FONT>
  868. parameter) and returns its size and unit (e.g. C<(20,POINTS)>). This can
  869. conviniently used in the gimp_text_..._fontname functions, which ignore the
  870. size (no joke ;). Example:
  871.  
  872.  $drawable->text_fontname (50, 50, "The quick", 5, 1, xlfd_size $font, $font;
  873.  
  874. =item Gimp::gtk_init()
  875.  
  876. Initialize Gtk in a similar way the Gimp itself did it. This automatically
  877. parses gimp's gtkrc and sets a variety of default settings (visual,
  878. colormap, gamma, shared memory...).
  879.  
  880. =item Gimp::gtk_init_add { init statements ... };
  881.  
  882. Add a callback function that should be called when gtk is being
  883. initialized (i.e. when Gimp::gtk_init is called, which should therefore be
  884. done even in Gnome applications).
  885.  
  886. This is different to Gtk->init_add, which only gets called in Gtk->main,
  887. which is too late for registering types.
  888.  
  889. =item Gimp::init([connection-argument]), Gimp::end()
  890.  
  891. These is an alternative interface that replaces the call to Gimp::main
  892. and the net callback. At the moment it only works for the Net interface
  893. (L<Gimp::Net>), and not as a native plug-in. Here's an example:
  894.  
  895.  use Gimp;
  896.  
  897.  Gimp::init;
  898.  <do something with the gimp>
  899.  
  900. The optional argument to init has the same format as the GIMP_HOST variable
  901. described in L<Gimp::Net>. Calling C<Gimp::end> is optional.
  902.  
  903. =item Gimp::lock(), Gimp::unlock()
  904.  
  905. These functions can be used to gain exclusive access to the Gimp. After
  906. calling lock, all accesses by other clients will be blocked and executed
  907. after the call to unlock. Calls to lock and unlock can be nested.
  908.  
  909. Currently, these functions only lock the current Perl-Server instance
  910. against exclusive access, they are nops when used via the Gimp::Lib
  911. interface.
  912.  
  913. =item Gimp::set_rgb_db(filespec)
  914.  
  915. Use the given rgb database instead of the default one. The format is
  916. the same as the one used by the X11 Consortiums rgb database (you might
  917. have a copy in /usr/lib/X11/rgb.txt). You can view the default database
  918. with C<perldoc -m Gimp>, at the end of the file (the default database is
  919. similar, but not identical to the X11 default rgb.txt)
  920.  
  921. =item Gimp::initialized()
  922.  
  923. this function returns true whenever it is safe to clal gimp functions. This is
  924. usually only the case after gimp_main or gimp_init have been called.
  925.  
  926. =item Gimp::register_callback(gimp_function_name,perl_function)
  927.  
  928. Using this fucntion you can overwrite the standard Gimp behaviour of
  929. calling a perl subroutine of the same name as the gimp function.
  930.  
  931. The first argument is the name of a registered gimp function that you want
  932. to overwrite ('perl_fu_make_something'), and the second argument can be
  933. either a name of the corresponding perl sub ('Elsewhere::make_something')
  934. or a code reference (\&my_make).
  935.  
  936. =back
  937.  
  938. =head1 SPECIAL METHODS
  939.  
  940. This chapter descibes methods that behave differently than you might
  941. expect, or methods uniquely implemented in perl (that is, not in the
  942. PDB). All of these must be invoked using the method syntax (C<Gimp-E<gt>>
  943. or C<$object-E<gt>>).
  944.  
  945. =over 4
  946.  
  947. =item gimp_install_procedure(name, blurb, help, author, copyright, date, menu_path, image_types, type, [params], [return_vals])
  948.  
  949. Mostly same as gimp_install_procedure. The parameters and return values for
  950. the functions are specified as an array ref containing either integers or
  951. array-refs with three elements, [PARAM_TYPE, \"NAME\", \"DESCRIPTION\"].
  952.  
  953. =item gimp_progress_init(message,[])
  954.  
  955. Initializes a progress bar. In networked modules this is a no-op.
  956.  
  957. =item gimp_progress_update(percentage)
  958.  
  959. Updates the progress bar. No-op in networked modules.
  960.  
  961. =item gimp_tile_*, gimp_pixel_rgn_*, gimp_drawable_get
  962.  
  963. With these functions you can access the raw pixel data of drawables. They
  964. are documented in L<Gimp::Pixel>, to keep this manual page short.
  965.  
  966. =item gimp_call_procedure(procname, arguments...)
  967.  
  968. This function is actually used to implement the fancy stuff. Its your basic
  969. interface to the PDB. Every function call is eventually done through his
  970. function, i.e.:
  971.  
  972.  gimp_image_new(args...);
  973.  
  974. is replaced by
  975.  
  976.  gimp_call_procedure "gimp_image_new",args...;
  977.  
  978. at runtime.
  979.  
  980. =item gimp_list_images, gimp_image_get_layers, gimp_image_get_channels
  981.  
  982. These functions return what you would expect: an array of images, layers or
  983. channels. The reason why this is documented is that the usual way to return
  984. C<PDB_INT32ARRAY>'s would be to return a B<reference> to an B<array of
  985. integers>, rather than blessed objects.
  986.  
  987. =item gimp_drawable_bounds drawable/gdrawable
  988.  
  989. Returns an array (x,y,w,h) containing the upper left corner and the
  990. size of currently selected parts of the drawable, just as needed by
  991. PixelRgn->new and similar functions.
  992.  
  993. =item server_eval(string)
  994.  
  995. This evaluates the given string in array context and returns the
  996. results. It's similar to C<eval>, but with two important differences: the
  997. evaluating always takes place on the server side/server machine (which
  998. might be the same as the local one) and compilation/runtime errors are
  999. reported as runtime errors (i.e. throwing an exception).
  1000.  
  1001. =back
  1002.  
  1003. =head1 OBJECT ORIENTED SYNTAX
  1004.  
  1005. In this manual, only the plain syntax (that lesser languages like C use) is
  1006. described. Actually, the recommended way to write gimp scripts is to use the
  1007. fancy OO-like syntax you are used to in perl (version 5 at least ;). As a
  1008. fact, OO-syntax saves soooo much typing as well. See L<Gimp::OO> for
  1009. details.
  1010.  
  1011. =head1 DEBUGGING AIDS
  1012.  
  1013. No, I can't tell you how to cure immune deficiencies (which might well be
  1014. uncurable, as AIDS virii might be able to survive in brain cells, among
  1015. other unreachable (for medication) parts of your body), but I I<can> tell
  1016. you how Gimp can help you debugging your scripts:
  1017.  
  1018. =over 4
  1019.  
  1020. =item Gimp::set_trace (tracemask)
  1021.  
  1022. Tracking down bugs in gimp scripts is difficult: no sensible error messages.
  1023. If anything goes wrong, you only get an execution failure. Switch on
  1024. tracing to see which parameters are used to call pdb functions.
  1025.  
  1026. This function is never exported, so you have to qualify it when calling.
  1027.  
  1028. tracemask is any number of the following flags or'ed together.
  1029.  
  1030. =over 8
  1031.  
  1032. =item TRACE_NONE
  1033.  
  1034. nothing is printed.
  1035.  
  1036. =item TRACE_CALL
  1037.  
  1038. all pdb calls (and only pdb calls!) are printed
  1039. with arguments and return values.
  1040.  
  1041. =item TRACE_TYPE
  1042.  
  1043. the parameter types are printed additionally.
  1044.  
  1045. =item TRACE_NAME
  1046.  
  1047. the parameter names are printed.
  1048.  
  1049. =item TRACE_DESC
  1050.  
  1051. the parameter descriptions.
  1052.  
  1053. =item TRACE_ALL
  1054.  
  1055. all of the above.
  1056.  
  1057. =back
  1058.  
  1059. C<set_trace> returns the old tracemask.
  1060.  
  1061. =item Gimp::set_trace(\$tracevar)
  1062.  
  1063. write trace into $tracevar instead of printing it to STDERR. $tracevar only
  1064. contains the last command traces, i.e. it's cleared on every PDB invocation
  1065. invocation.
  1066.  
  1067. =item Gimp::set_trace(*FILEHANDLE)
  1068.  
  1069. write trace to FILEHANDLE instead of STDERR.
  1070.  
  1071. =back
  1072.  
  1073. =head1 SUPPORTED GIMP DATA TYPES
  1074.  
  1075. Gimp supports different data types like colors, regions, strings. In
  1076. perl, these are represented as:
  1077.  
  1078. =over 4
  1079.  
  1080. =item INT32, INT16, INT8, FLOAT, STRING
  1081.  
  1082. normal perl scalars. Anything except STRING will be mapped
  1083. to a perl-double.
  1084.  
  1085. =item INT32ARRAY, INT16ARRAY, INT8ARRAY, FLOATARRAY, STRINGARRAY
  1086.  
  1087. array refs containing scalars of the same type, i.e. [1, 2, 3, 4]. Gimp
  1088. implicitly swallows or generates a preceeding integer argument because the
  1089. preceding argument usually (this is a de-facto standard) contains the number
  1090. of elements.
  1091.  
  1092. =item COLOR
  1093.  
  1094. on input, either an array ref with 3 elements (i.e. [233,40,40]), a X11-like
  1095. string ("#rrggbb") or a colour name ("papayawhip") (see set_rgb_db).
  1096.  
  1097. =item DISPLAY, IMAGE, LAYER, CHANNEL, DRAWABLE, SELECTION
  1098.  
  1099. these will be mapped to corresponding objects (IMAGE => Gimp::Image). In trace
  1100. output you will see small integers (the image/layer/etc..-ID)
  1101.  
  1102. =item PARASITE
  1103.  
  1104. represented as an array ref [name, flags, data], where name and data should be perl strings
  1105. and flags is the numerical flag value.
  1106.  
  1107. =item REGION, BOUNDARY, PATH, STATUS
  1108.  
  1109. Not yet supported (and might never be).
  1110.  
  1111. =back
  1112.  
  1113. =head1 AUTHOR
  1114.  
  1115. Marc Lehmann <pcg@goof.com>
  1116.  
  1117. =head1 SEE ALSO
  1118.  
  1119. perl(1), gimp(1), L<Gimp::OO>, L<Gimp::Data>, L<Gimp::Pixel>, L<Gimp::PDL>, L<Gimp::Util>, L<Gimp::UI>, L<Gimp::Feature>, L<Gimp::Net>,
  1120. L<Gimp::Compat>, L<Gimp::Config>, L<Gimp::Lib>, L<Gimp::Module>, L<scm2perl> and L<scm2scm>.
  1121.  
  1122. =cut
  1123.  
  1124. __DATA__
  1125. 240 248 255        AliceBlue
  1126. 250 235 215        AntiqueWhite
  1127. 255 239 219        AntiqueWhite1
  1128. 238 223 204        AntiqueWhite2
  1129. 205 192 176        AntiqueWhite3
  1130. 139 131 120        AntiqueWhite4
  1131. 255 235 205        BlanchedAlmond
  1132. 138  43 226        BlueViolet
  1133.  95 153 159        CadetBlue
  1134. 152 245 255        CadetBlue1
  1135. 142 229 238        CadetBlue2
  1136. 122 197 205        CadetBlue3
  1137.  83 134 139        CadetBlue4
  1138.  34  34 152        CornflowerBlue
  1139. 0     0 139        DarkBlue
  1140. 0   139 139        DarkCyan
  1141. 184 134  11        DarkGoldenrod
  1142. 255 185     15        DarkGoldenrod1
  1143. 238 173     14        DarkGoldenrod2
  1144. 205 149     12        DarkGoldenrod3
  1145. 139 101      8        DarkGoldenrod4
  1146. 169 169 169        DarkGray
  1147.   0  83   0        DarkGreen
  1148. 169 169 169        DarkGrey
  1149. 189 183 107        DarkKhaki
  1150. 139   0 139        DarkMagenta
  1151.  85 107  47        DarkOliveGreen
  1152. 202 255 112        DarkOliveGreen1
  1153. 188 238 104        DarkOliveGreen2
  1154. 162 205     90        DarkOliveGreen3
  1155. 110 139     61        DarkOliveGreen4
  1156. 255 127   0        DarkOrange
  1157. 255 127      0        DarkOrange1
  1158. 238 118      0        DarkOrange2
  1159. 205 102      0        DarkOrange3
  1160. 139  69      0        DarkOrange4
  1161. 153  50 204        DarkOrchid
  1162. 191  62 255        DarkOrchid1
  1163. 178  58 238        DarkOrchid2
  1164. 154  50 205        DarkOrchid3
  1165. 104  34 139        DarkOrchid4
  1166. 139   0   0        DarkRed
  1167. 233 150 122        DarkSalmon
  1168. 143 188 143        DarkSeaGreen
  1169. 193 255 193        DarkSeaGreen1
  1170. 180 238 180        DarkSeaGreen2
  1171. 155 205 155        DarkSeaGreen3
  1172. 105 139 105        DarkSeaGreen4
  1173.  72  61 139        DarkSlateBlue
  1174.  47  79  79        DarkSlateGray
  1175. 151 255 255        DarkSlateGray1
  1176. 141 238 238        DarkSlateGray2
  1177. 121 205 205        DarkSlateGray3
  1178.  82 139 139        DarkSlateGray4
  1179.  47  79  79        DarkSlateGrey
  1180.   0 195 205        DarkTurquoise
  1181. 148   0 211        DarkViolet
  1182. 255  20 147        DeepPink
  1183. 255  20 147        DeepPink1
  1184. 238  18 137        DeepPink2
  1185. 205  16 118        DeepPink3
  1186. 139  10     80        DeepPink4
  1187.   0 191 255        DeepSkyBlue
  1188.   0 191 255        DeepSkyBlue1
  1189.   0 178 238        DeepSkyBlue2
  1190.   0 154 205        DeepSkyBlue3
  1191.   0 104 139        DeepSkyBlue4
  1192. 105 105 105        DimGray
  1193. 105 105 105        DimGrey
  1194.  30 144 255        DodgerBlue
  1195.  30 144 255        DodgerBlue1
  1196.  28 134 238        DodgerBlue2
  1197.  24 116 205        DodgerBlue3
  1198.  16  78 139        DodgerBlue4
  1199.  58  95 205        FlatMediumBlue
  1200.  72 118 255        FlatMediumBlue1
  1201.  67 110 238        FlatMediumBlue2
  1202.  58  95 205        FlatMediumBlue3
  1203.  39  64 139        FlatMediumBlue4
  1204. 143 188 143        FlatMediumGreen
  1205. 193 255 193        FlatMediumGreen1
  1206. 180 238 180        FlatMediumGreen2
  1207. 155 205 155        FlatMediumGreen3
  1208. 105 139 105        FlatMediumGreen4
  1209. 255 250 240        FloralWhite
  1210.  34 139  34        ForestGreen
  1211. 248 248 255        GhostWhite
  1212. 173 255  47        GreenYellow
  1213. 255 105 180        HotPink
  1214. 255 110 180        HotPink1
  1215. 238 106 167        HotPink2
  1216. 205  96 144        HotPink3
  1217. 139  58  98        HotPink4
  1218. 139  58  58        IndianRed
  1219. 255 106 106        IndianRed1
  1220. 238  99     99        IndianRed2
  1221. 205  85     85        IndianRed3
  1222. 139  58     58        IndianRed4
  1223. 255 240 245        LavenderBlush
  1224. 255 240 245        LavenderBlush1
  1225. 238 224 229        LavenderBlush2
  1226. 205 193 197        LavenderBlush3
  1227. 139 131 134        LavenderBlush4
  1228. 124 252   0        LawnGreen
  1229. 255 250 205        LemonChiffon
  1230. 255 250 205        LemonChiffon1
  1231. 238 233 191        LemonChiffon2
  1232. 205 201 165        LemonChiffon3
  1233. 139 137 112        LemonChiffon4
  1234. 173 216 230        LightBlue
  1235. 191 239 255        LightBlue1
  1236. 178 223 238        LightBlue2
  1237. 154 192 205        LightBlue3
  1238. 104 131 139        LightBlue4
  1239. 240 128 128        LightCoral
  1240. 224 255 255        LightCyan
  1241. 224 255 255        LightCyan1
  1242. 209 238 238        LightCyan2
  1243. 180 205 205        LightCyan3
  1244. 122 139 139        LightCyan4
  1245. 238 221 130        LightGoldenrod
  1246. 255 236 139        LightGoldenrod1
  1247. 238 220 130        LightGoldenrod2
  1248. 205 190 112        LightGoldenrod3
  1249. 139 129     76        LightGoldenrod4
  1250. 250 250 210        LightGoldenrodYellow
  1251. 211 211 211        LightGray
  1252. 144 238 144        LightGreen
  1253. 211 211 211        LightGrey
  1254. 255 174 185        LightPink
  1255. 255 174 185        LightPink1
  1256. 238 162 173        LightPink2
  1257. 205 140 149        LightPink3
  1258. 139  95 101        LightPink4
  1259. 255 160 122        LightSalmon
  1260. 255 160 122        LightSalmon1
  1261. 238 149 114        LightSalmon2
  1262. 205 129     98        LightSalmon3
  1263. 139  87     66        LightSalmon4
  1264.  32 178 170        LightSeaGreen
  1265. 176 226 255        LightSkyBlue
  1266. 176 226 255        LightSkyBlue1
  1267. 164 211 238        LightSkyBlue2
  1268. 141 182 205        LightSkyBlue3
  1269.  96 123 139        LightSkyBlue4
  1270. 132 112 255        LightSlateBlue
  1271. 119 136 153        LightSlateGray
  1272. 119 136 153        LightSlateGrey
  1273.  176 196 222        LightSteelBlue
  1274. 202 225 255        LightSteelBlue1
  1275. 188 210 238        LightSteelBlue2
  1276. 162 181 205        LightSteelBlue3
  1277. 110 123 139        LightSteelBlue4
  1278. 255 255 224        LightYellow
  1279. 255 255 224        LightYellow1
  1280. 238 238 209        LightYellow2
  1281. 205 205 180        LightYellow3
  1282. 139 139 122        LightYellow4
  1283.  50 205  50        LimeGreen
  1284. 102 205 170        MediumAquamarine
  1285.   0   0 205        MediumBlue
  1286. 107 142  35        MediumForestGreen
  1287. 184 134  11        MediumGoldenrod
  1288. 255 185     15        MediumGoldenrod1
  1289. 238 173     14        MediumGoldenrod2
  1290. 205 149     12        MediumGoldenrod3
  1291. 139 101      8        MediumGoldenrod4
  1292. 186  85 211        MediumOrchid
  1293. 224 102 255        MediumOrchid1
  1294. 209  95 238        MediumOrchid2
  1295. 180  82 205        MediumOrchid3
  1296. 122  55 139        MediumOrchid4
  1297. 255 125 179        MediumPink
  1298. 255 125 179        MediumPink1
  1299. 238 116 167        MediumPink2
  1300. 205 100 144        MediumPink3
  1301. 139  68     98        MediumPink4
  1302. 147 112 219        MediumPurple
  1303. 171 130 255        MediumPurple1
  1304. 159 121 238        MediumPurple2
  1305. 137 104 205        MediumPurple3
  1306.  93  71 139        MediumPurple4
  1307.  60 179 113        MediumSeaGreen
  1308. 123 104 238        MediumSlateBlue
  1309. 127 255   0        MediumSpringGreen
  1310.   0 227 238        MediumTurquoise
  1311. 199  21 133        MediumVioletRed
  1312.  25  25 100        MidnightBlue
  1313. 245 255 250        MintCream
  1314. 255 228 225        MistyRose
  1315. 255 228 225        MistyRose1
  1316. 238 213 210        MistyRose2
  1317. 205 183 181        MistyRose3
  1318. 139 125 123        MistyRose4
  1319. 255 222 173        NavajoWhite
  1320. 255 222 173        NavajoWhite1
  1321. 238 207 161        NavajoWhite2
  1322. 205 179 139        NavajoWhite3
  1323. 139 121     94        NavajoWhite4
  1324.  34  34 139        NavyBlue
  1325. 238 221 130        OldGoldenrod
  1326. 255 236 139        OldGoldenrod1
  1327. 238 220 130        OldGoldenrod2
  1328. 205 190 112        OldGoldenrod3
  1329. 139 129     76        OldGoldenrod4
  1330. 253 245 230        OldLace
  1331. 238 238 175        OldMediumGoldenrod
  1332. 255 255 187        OldMediumGoldenrod1
  1333. 238 238 174        OldMediumGoldenrod2
  1334. 205 205 150        OldMediumGoldenrod3
  1335. 139 139 102        OldMediumGoldenrod4
  1336. 107 142  35        OliveDrab
  1337. 192 255     62        OliveDrab1
  1338. 179 238     58        OliveDrab2
  1339. 154 205     50        OliveDrab3
  1340. 105 139     34        OliveDrab4
  1341. 255  69   0        OrangeRed
  1342. 255  69      0        OrangeRed1
  1343. 238  64      0        OrangeRed2
  1344. 205  55      0        OrangeRed3
  1345. 139  37      0        OrangeRed4
  1346. 238 232 170        PaleGoldenrod
  1347. 152 251 152        PaleGreen
  1348. 154 255 154        PaleGreen1
  1349. 144 238 144        PaleGreen2
  1350. 124 205 124        PaleGreen3
  1351.  84 139     84        PaleGreen4
  1352. 255 170 200        PalePink
  1353. 175 238 238        PaleTurquoise
  1354. 187 255 255        PaleTurquoise1
  1355. 174 238 238        PaleTurquoise2
  1356. 150 205 205        PaleTurquoise3
  1357. 102 139 139        PaleTurquoise4
  1358. 219 112 147        PaleVioletRed
  1359. 255 130 171        PaleVioletRed1
  1360. 238 121 159        PaleVioletRed2
  1361. 205 104 137        PaleVioletRed3
  1362. 139  71     93        PaleVioletRed4
  1363. 255 239 213        PapayaWhip
  1364. 255 218 185        PeachPuff
  1365. 255 218 185        PeachPuff1
  1366. 238 203 173        PeachPuff2
  1367. 205 175 149        PeachPuff3
  1368. 139 119 101        PeachPuff4
  1369. 176 224 230        PowderBlue
  1370. 188 143 143        RosyBrown
  1371. 255 193 193        RosyBrown1
  1372. 238 180 180        RosyBrown2
  1373. 205 155 155        RosyBrown3
  1374. 139 105 105        RosyBrown4
  1375.  65 105 225        RoyalBlue
  1376.  72 118 255        RoyalBlue1
  1377.  67 110 238        RoyalBlue2
  1378.  58  95 205        RoyalBlue3
  1379.  39  64 139        RoyalBlue4
  1380. 139  69  19        SaddleBrown
  1381. 244 164  96        SandyBrown
  1382.  46 139  87        SeaGreen
  1383.  84 255 159        SeaGreen1
  1384.  78 238 148        SeaGreen2
  1385.  67 205 128        SeaGreen3
  1386.  46 139     87        SeaGreen4
  1387. 135 206 255        SkyBlue
  1388. 135 206 255        SkyBlue1
  1389. 126 192 238        SkyBlue2
  1390. 108 166 205        SkyBlue3
  1391.  74 112 139        SkyBlue4
  1392. 106  90 205        SlateBlue
  1393. 131 111 255        SlateBlue1
  1394. 122 103 238        SlateBlue2
  1395. 105  89 205        SlateBlue3
  1396.  71  60 139        SlateBlue4
  1397. 112 128 144        SlateGray
  1398. 198 226 255        SlateGray1
  1399. 185 211 238        SlateGray2
  1400. 159 182 205        SlateGray3
  1401. 108 123 139        SlateGray4
  1402. 112 128 144        SlateGrey
  1403.   0 255 127        SpringGreen
  1404.   0 255 127        SpringGreen1
  1405.   0 238 118        SpringGreen2
  1406.   0 205 102        SpringGreen3
  1407.   0 139     69        SpringGreen4
  1408.  70 130 180        SteelBlue
  1409.  99 184 255        SteelBlue1
  1410.  92 172 238        SteelBlue2
  1411.  79 148 205        SteelBlue3
  1412.  54 100 139        SteelBlue4
  1413. 255  62 150        VioletRed
  1414. 255  62 150        VioletRed1
  1415. 238  58 140        VioletRed2
  1416. 205  50 120        VioletRed3
  1417. 139  34     82        VioletRed4
  1418. 245 245 245        WhiteSmoke
  1419. 154 205  50        YellowGreen
  1420. 240 248 255        alice blue
  1421. 250 235 215        antique white
  1422. 41 171 151        aquamarine
  1423. 127 255 212        aquamarine1
  1424. 118 238 198        aquamarine2
  1425. 102 205 170        aquamarine3
  1426.  69 139 116        aquamarine4
  1427. 240 255 255        azure
  1428. 240 255 255        azure1
  1429. 224 238 238        azure2
  1430. 193 205 205        azure3
  1431. 131 139 139        azure4
  1432. 245 245 220        beige
  1433. 255 228 196        bisque
  1434. 255 228 196        bisque1
  1435. 238 213 183        bisque2
  1436. 205 183 158        bisque3
  1437. 139 125 107        bisque4
  1438. 0 0 0            black
  1439. 255 235 205        blanched almond
  1440. 0 0 255            blue
  1441. 114 33 188        blue violet
  1442.   0   0 255        blue1
  1443.   0   0 238        blue2
  1444.   0   0 205        blue3
  1445.   0   0 139        blue4
  1446. 103 67 0        brown
  1447. 255  64     64        brown1
  1448. 238  59     59        brown2
  1449. 205  51     51        brown3
  1450. 139  35     35        brown4
  1451. 222 184 135        burlywood
  1452. 255 211 155        burlywood1
  1453. 238 197 145        burlywood2
  1454. 205 170 125        burlywood3
  1455. 139 115     85        burlywood4
  1456. 126 125 160        cadet blue
  1457. 127 255   0        chartreuse
  1458. 127 255      0        chartreuse1
  1459. 118 238      0        chartreuse2
  1460. 102 205      0        chartreuse3
  1461.  69 139      0        chartreuse4
  1462. 210 105  30        chocolate
  1463. 255 127     36        chocolate1
  1464. 238 118     33        chocolate2
  1465. 205 102     29        chocolate3
  1466. 139  69     19        chocolate4
  1467. 248 137 117        coral
  1468. 255 114     86        coral1
  1469. 238 106     80        coral2
  1470. 205  91     69        coral3
  1471. 139  62     47        coral4
  1472. 100 149 237        cornflower blue
  1473. 255 248 220        cornsilk
  1474. 255 248 220        cornsilk1
  1475. 238 232 205        cornsilk2
  1476. 205 200 177        cornsilk3
  1477. 139 136 120        cornsilk4
  1478. 0 255 255        cyan
  1479.   0 255 255        cyan1
  1480.   0 238 238        cyan2
  1481.   0 205 205        cyan3
  1482.   0 139 139        cyan4
  1483. 0     0 139        dark blue
  1484. 0   139 139        dark cyan
  1485. 184 134  11        dark goldenrod
  1486. 169 169 169        dark gray
  1487. 0 83 0            dark green
  1488. 169 169 169        dark grey
  1489. 189 183 107        dark khaki
  1490. 139   0 139        dark magenta
  1491. 79 79 47        dark olive green
  1492. 255 127   0        dark orange
  1493. 106 37 102        dark orchid
  1494. 139   0   0        dark red
  1495. 233 150 122        dark salmon
  1496. 143 188 143        dark sea green
  1497. 51 62 99        dark slate blue
  1498. 60 64 74        dark slate gray
  1499. 60 64 74        dark slate grey
  1500. 29 111 117        dark turquoise
  1501. 148   0 211        dark violet
  1502. 255  20 147        deep pink
  1503.   0 191 255        deep sky blue
  1504. 105 105 105        dim gray
  1505. 105 105 105        dim grey
  1506.  30 144 255        dodger blue
  1507. 136 18 13        firebrick
  1508. 255  48     48        firebrick1
  1509. 238  44     44        firebrick2
  1510. 205  38     38        firebrick3
  1511. 139  26     26        firebrick4
  1512.  58  95 205        flat medium blue
  1513. 143 188 143        flat medium green
  1514. 255 250 240        floral white
  1515. 85 192 52        forest green
  1516. 220 220 220        gainsboro
  1517. 248 248 255        ghost white
  1518. 254 197 68        gold
  1519. 255 215      0        gold1
  1520. 238 201      0        gold2
  1521. 205 173      0        gold3
  1522. 139 117      0        gold4
  1523. 218 165 32        goldenrod
  1524. 255 193     37        goldenrod1
  1525. 238 180     34        goldenrod2
  1526. 205 155     29        goldenrod3
  1527. 139 105     20        goldenrod4
  1528. 174 174 174        gray
  1529. 0 0 0             gray0
  1530. 3 3 3             gray1
  1531. 26 26 26         gray10
  1532. 255 255 255         gray100
  1533. 28 28 28         gray11
  1534. 31 31 31         gray12
  1535. 33 33 33         gray13
  1536. 36 36 36         gray14
  1537. 38 38 38         gray15
  1538. 41 41 41         gray16
  1539. 43 43 43         gray17
  1540. 46 46 46         gray18
  1541. 48 48 48         gray19
  1542. 5 5 5             gray2
  1543. 51 51 51         gray20
  1544. 54 54 54         gray21
  1545. 56 56 56         gray22
  1546. 59 59 59         gray23
  1547. 61 61 61         gray24
  1548. 64 64 64         gray25
  1549. 66 66 66         gray26
  1550. 69 69 69         gray27
  1551. 71 71 71         gray28
  1552. 74 74 74         gray29
  1553. 8 8 8             gray3
  1554. 77 77 77         gray30
  1555. 79 79 79         gray31
  1556. 82 82 82         gray32
  1557. 84 84 84         gray33
  1558. 87 87 87         gray34
  1559. 89 89 89         gray35
  1560. 92 92 92         gray36
  1561. 94 94 94         gray37
  1562. 97 97 97         gray38
  1563. 99 99 99         gray39
  1564. 10 10 10         gray4
  1565. 102 102 102         gray40
  1566. 105 105 105         gray41
  1567. 107 107 107         gray42
  1568. 110 110 110         gray43
  1569. 112 112 112         gray44
  1570. 115 115 115         gray45
  1571. 117 117 117         gray46
  1572. 120 120 120         gray47
  1573. 122 122 122         gray48
  1574. 125 125 125         gray49
  1575. 13 13 13         gray5
  1576. 127 127 127         gray50
  1577. 130 130 130         gray51
  1578. 133 133 133         gray52
  1579. 135 135 135         gray53
  1580. 138 138 138         gray54
  1581. 140 140 140         gray55
  1582. 143 143 143         gray56
  1583. 145 145 145         gray57
  1584. 148 148 148         gray58
  1585. 150 150 150         gray59
  1586. 15 15 15         gray6
  1587. 153 153 153         gray60
  1588. 156 156 156         gray61
  1589. 158 158 158         gray62
  1590. 161 161 161         gray63
  1591. 163 163 163         gray64
  1592. 166 166 166         gray65
  1593. 168 168 168         gray66
  1594. 171 171 171         gray67
  1595. 173 173 173         gray68
  1596. 176 176 176         gray69
  1597. 18 18 18         gray7
  1598. 179 179 179         gray70
  1599. 181 181 181         gray71
  1600. 184 184 184         gray72
  1601. 186 186 186         gray73
  1602. 189 189 189         gray74
  1603. 191 191 191         gray75
  1604. 194 194 194         gray76
  1605. 196 196 196         gray77
  1606. 199 199 199         gray78
  1607. 201 201 201         gray79
  1608. 20 20 20         gray8
  1609. 204 204 204         gray80
  1610. 207 207 207         gray81
  1611. 209 209 209         gray82
  1612. 212 212 212         gray83
  1613. 214 214 214         gray84
  1614. 217 217 217         gray85
  1615. 219 219 219         gray86
  1616. 222 222 222         gray87
  1617. 224 224 224         gray88
  1618. 227 227 227         gray89
  1619. 23 23 23         gray9
  1620. 229 229 229         gray90
  1621. 232 232 232         gray91
  1622. 235 235 235         gray92
  1623. 237 237 237         gray93
  1624. 240 240 240         gray94
  1625. 242 242 242         gray95
  1626. 245 245 245         gray96
  1627. 247 247 247         gray97
  1628. 250 250 250         gray98
  1629. 252 252 252         gray99
  1630. 0 255 0            green
  1631. 159 211 0        green yellow
  1632.   0 255      0        green1
  1633.   0 238      0        green2
  1634.   0 205      0        green3
  1635.   0 139      0        green4
  1636. 174 174 174        grey
  1637. 0 0 0             grey0
  1638. 3 3 3             grey1
  1639. 26 26 26         grey10
  1640. 255 255 255         grey100
  1641. 28 28 28         grey11
  1642. 31 31 31         grey12
  1643. 33 33 33         grey13
  1644. 36 36 36         grey14
  1645. 38 38 38         grey15
  1646. 41 41 41         grey16
  1647. 43 43 43         grey17
  1648. 46 46 46         grey18
  1649. 48 48 48         grey19
  1650. 5 5 5             grey2
  1651. 51 51 51         grey20
  1652. 54 54 54         grey21
  1653. 56 56 56         grey22
  1654. 59 59 59         grey23
  1655. 61 61 61         grey24
  1656. 64 64 64         grey25
  1657. 66 66 66         grey26
  1658. 69 69 69         grey27
  1659. 71 71 71         grey28
  1660. 74 74 74         grey29
  1661. 8 8 8             grey3
  1662. 77 77 77         grey30
  1663. 79 79 79         grey31
  1664. 82 82 82         grey32
  1665. 84 84 84         grey33
  1666. 87 87 87         grey34
  1667. 89 89 89         grey35
  1668. 92 92 92         grey36
  1669. 94 94 94         grey37
  1670. 97 97 97         grey38
  1671. 99 99 99         grey39
  1672. 10 10 10         grey4
  1673. 102 102 102         grey40
  1674. 105 105 105         grey41
  1675. 107 107 107         grey42
  1676. 110 110 110         grey43
  1677. 112 112 112         grey44
  1678. 115 115 115         grey45
  1679. 117 117 117         grey46
  1680. 120 120 120         grey47
  1681. 122 122 122         grey48
  1682. 125 125 125         grey49
  1683. 13 13 13         grey5
  1684. 127 127 127         grey50
  1685. 130 130 130         grey51
  1686. 133 133 133         grey52
  1687. 135 135 135         grey53
  1688. 138 138 138         grey54
  1689. 140 140 140         grey55
  1690. 143 143 143         grey56
  1691. 145 145 145         grey57
  1692. 148 148 148         grey58
  1693. 150 150 150         grey59
  1694. 15 15 15         grey6
  1695. 153 153 153         grey60
  1696. 156 156 156         grey61
  1697. 158 158 158         grey62
  1698. 161 161 161         grey63
  1699. 163 163 163         grey64
  1700. 166 166 166         grey65
  1701. 168 168 168         grey66
  1702. 171 171 171         grey67
  1703. 173 173 173         grey68
  1704. 176 176 176         grey69
  1705. 18 18 18         grey7
  1706. 179 179 179         grey70
  1707. 181 181 181         grey71
  1708. 184 184 184         grey72
  1709. 186 186 186         grey73
  1710. 189 189 189         grey74
  1711. 191 191 191         grey75
  1712. 194 194 194         grey76
  1713. 196 196 196         grey77
  1714. 199 199 199         grey78
  1715. 201 201 201         grey79
  1716. 20 20 20         grey8
  1717. 204 204 204         grey80
  1718. 207 207 207         grey81
  1719. 209 209 209         grey82
  1720. 212 212 212         grey83
  1721. 214 214 214         grey84
  1722. 217 217 217         grey85
  1723. 219 219 219         grey86
  1724. 222 222 222         grey87
  1725. 224 224 224         grey88
  1726. 227 227 227         grey89
  1727. 23 23 23         grey9
  1728. 229 229 229         grey90
  1729. 232 232 232         grey91
  1730. 235 235 235         grey92
  1731. 237 237 237         grey93
  1732. 240 240 240         grey94
  1733. 242 242 242         grey95
  1734. 245 245 245         grey96
  1735. 247 247 247         grey97
  1736. 250 250 250         grey98
  1737. 252 252 252         grey99
  1738. 240 255 240        honeydew
  1739. 240 255 240        honeydew1
  1740. 224 238 224        honeydew2
  1741. 193 205 193        honeydew3
  1742. 131 139 131        honeydew4
  1743. 255 105 180        hot pink
  1744. 101 46 46        indian red
  1745. 255 255 240        ivory
  1746. 255 255 240        ivory1
  1747. 238 238 224        ivory2
  1748. 205 205 193        ivory3
  1749. 139 139 131        ivory4
  1750. 189 167 107        khaki
  1751. 255 246 143        khaki1
  1752. 238 230 133        khaki2
  1753. 205 198 115        khaki3
  1754. 139 134     78        khaki4
  1755. 230 230 250        lavender
  1756. 255 240 245        lavender blush
  1757. 124 252   0        lawn green
  1758. 255 250 205        lemon chiffon
  1759. 171 197 255        light blue
  1760. 240 128 128        light coral
  1761. 224 255 255        light cyan
  1762. 238 221 130        light goldenrod
  1763. 250 250 210        light goldenrod yellow
  1764. 211 211 211        light gray
  1765. 144 238 144        light green
  1766. 211 211 211        light grey
  1767. 255 174 185        light pink
  1768. 255 160 122        light salmon
  1769.  32 178 170        light sea green
  1770. 176 226 255        light sky blue
  1771. 132 112 255        light slate blue
  1772. 119 136 153        light slate gray
  1773. 119 136 153        light slate grey
  1774. 52 152 202        light steel blue
  1775. 255 255 224        light yellow
  1776. 46 155 28        lime green
  1777. 250 240 230        linen
  1778. 255 0 211        magenta
  1779. 255   0 255        magenta1
  1780. 238   0 238        magenta2
  1781. 205   0 205        magenta3
  1782. 139   0 139        magenta4
  1783. 103 7 72        maroon
  1784. 255  52 179        maroon1
  1785. 238  48 167        maroon2
  1786. 205  41 144        maroon3
  1787. 139  28     98        maroon4
  1788. 21 135 118        medium aquamarine
  1789. 61 98 208        medium blue
  1790. 107 142 35        medium forest green
  1791. 184 134 11        medium goldenrod
  1792. 172 77 166        medium orchid
  1793. 255 125 179        medium pink
  1794. 147 112 219        medium purple
  1795. 27 134 86        medium sea green
  1796. 95 109 154        medium slate blue
  1797. 60 141 35        medium spring green
  1798. 62 172 181        medium turquoise
  1799. 199 21 133        medium violet red
  1800. 12 62 99        midnight blue
  1801. 245 255 250        mint cream
  1802. 255 228 225        misty rose
  1803. 255 228 181        moccasin
  1804. 255 222 173        navajo white
  1805. 0 0 142            navy
  1806. 0 0 142            navy blue
  1807. 238 221 130        old goldenrod
  1808. 253 245 230        old lace
  1809. 238 238 175        old medium goldenrod
  1810. 107 142  35        olive drab
  1811. 255 138 0        orange
  1812. 226 65 42        orange red
  1813. 255 165      0        orange1
  1814. 238 154      0        orange2
  1815. 205 133      0        orange3
  1816. 139  90      0        orange4
  1817. 218 107 212        orchid
  1818. 255 131 250        orchid1
  1819. 238 122 233        orchid2
  1820. 205 105 201        orchid3
  1821. 139  71 137        orchid4
  1822. 238 232 170        pale goldenrod
  1823. 152 255 152        pale green
  1824. 255 170 200        pale pink
  1825. 175 238 238        pale turquoise
  1826. 219 112 147        pale violet red
  1827. 255 239 213        papaya whip
  1828. 255 218 185        peach puff
  1829. 205 133  63        peru
  1830. 255 174 185        pink
  1831. 255 181 197        pink1
  1832. 238 169 184        pink2
  1833. 205 145 158        pink3
  1834. 139  99 108        pink4
  1835. 76 46 87        plum
  1836. 255 187 255        plum1
  1837. 238 174 238        plum2
  1838. 205 150 205        plum3
  1839. 139 102 139        plum4
  1840. 176 224 230        powder blue
  1841. 138  43 226        purple
  1842. 155  48 255        purple1
  1843. 145  44 238        purple2
  1844. 125  38 205        purple3
  1845.  85  26 139        purple4
  1846. 255 0 0            red
  1847. 255   0      0        red1
  1848. 238   0      0        red2
  1849. 205   0      0        red3
  1850. 139   0      0        red4
  1851. 188 143 143        rosy brown
  1852.  65 105 225        royal blue
  1853. 139  69  19        saddle brown
  1854. 248 109 104        salmon
  1855. 255 140 105        salmon1
  1856. 238 130     98        salmon2
  1857. 205 112     84        salmon3
  1858. 139  76     57        salmon4
  1859. 178 143 86        sandy brown
  1860. 43 167 112        sea green
  1861. 255 245 238        seashell
  1862. 255 245 238        seashell1
  1863. 238 229 222        seashell2
  1864. 205 197 191        seashell3
  1865. 139 134 130        seashell4
  1866. 142 107 35        sienna
  1867. 255 130     71        sienna1
  1868. 238 121     66        sienna2
  1869. 205 104     57        sienna3
  1870. 139  71     38        sienna4
  1871. 0 138 255        sky blue
  1872. 117 134 190        slate blue
  1873. 112 128 144        slate gray
  1874. 112 128 144        slate grey
  1875. 255 250 250        snow
  1876. 255 250 250        snow1
  1877. 238 233 233        snow2
  1878. 205 201 201        snow3
  1879. 139 137 137        snow4
  1880. 0 255 159        spring green
  1881. 55 121 153        steel blue
  1882. 176 155 125        tan
  1883. 255 165     79        tan1
  1884. 238 154     73        tan2
  1885. 205 133     63        tan3
  1886. 139  90     43        tan4
  1887. 146 62 112        thistle
  1888. 255 225 255        thistle1
  1889. 238 210 238        thistle2
  1890. 205 181 205        thistle3
  1891. 139 123 139        thistle4
  1892. 255  99  71        tomato
  1893. 255  99     71        tomato1
  1894. 238  92     66        tomato2
  1895. 205  79     57        tomato3
  1896. 139  54     38        tomato4
  1897. 72 209 204        turquoise
  1898.   0 245 255        turquoise1
  1899.   0 229 238        turquoise2
  1900.   0 197 205        turquoise3
  1901.   0 134 139        turquoise4
  1902. 148 0 211        violet
  1903. 255 0 148        violet red
  1904. 229 199 117        wheat
  1905. 255 231 186        wheat1
  1906. 238 216 174        wheat2
  1907. 205 186 150        wheat3
  1908. 139 126 102        wheat4
  1909. 255 255 255        white
  1910. 245 245 245        white smoke
  1911. 255 255 0        yellow
  1912. 75 211 0         yellow green
  1913. 255 255      0        yellow1
  1914. 238 238      0        yellow2
  1915. 205 205      0        yellow3
  1916. 139 139      0        yellow4
  1917.